package com.vitabuybuy.tv.ui.mine.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.vitabuybuy.tv.R
import com.vitabuybuy.tv.databinding.ItemCollectGoodsBinding
import com.vitabuybuy.tv.dto.MyCollectListDto
import com.library.common.base.BindRecycAdapter

class CollectionCommodityListAdapter :
    BindRecycAdapter<ItemCollectGoodsBinding, MyCollectListDto>() {
    var isEdit = false
    override fun normalViewId(viewType: Int): Int {
        return R.layout.item_collect_goods
    }
    override fun onBindViewHolder(
        mBinding: ItemCollectGoodsBinding,
        itemData: MyCollectListDto,
        holder: RecyclerView.ViewHolder,
        position: Int
    ) {
        mBinding.itemData = itemData
        mBinding.ivChoose.visibility = if(isEdit) View.VISIBLE else View.GONE

        mBinding.ivChoose.setOnClickListener {
            chooseCollectItem.invoke(position)
        }
        mBinding.btnDelete.setOnClickListener {
            cancelCollect.invoke(position)
        }
        mBinding.ivBuy.setOnClickListener {
            addToCart.invoke(position)
        }
        mBinding.clGoodeCard.setOnClickListener {
            itemClickListener.invoke(itemData.product.id)
        }
    }

    lateinit var itemClickListener: (id:Int) -> Unit
    lateinit var addToCart: (position:Int) -> Unit
    lateinit var chooseCollectItem: (position:Int) -> Unit
    lateinit var cancelCollect: (position:Int) -> Unit
}
